frappe.listview_settings['Packing Order'] = {

    add_fields: ['status'],
    // hide_name_column: true,
    // hide_name_filter: true, 
    onload(listview) {
        // triggers once before the list is loaded
        if(frappe.user.has_role("Packing Process") || frappe.user.has_role("System Manager")){
            listview.page.add_action_item(__("Packing Process"), function() {
                docnames = listview.get_checked_items(true)
                console.log(docnames)
                frappe.call({
                    method: "zy_packlist.zy_packlist.doctype.packing_order.packing_order.create_packing_process",
                    args: {
                        order_list: docnames,
                    },
                }).then((r) => {
                    // console.log(r.message)
                    frappe.set_route("Form", r.message.doctype, r.message.name);
                });    
            });

        }

    },

    get_indicator(doc) {
        // customize indicator color
        if (doc.status === "Draft") {
            return [__("Draft"), "black", "status,=,Draft"];
        } else if (doc.status === "Submitted") {
            return [__("Submitted"), "blue", "status,=,Submitted"];
        }else if (doc.status === "Cancelled") {
            return [__("Cancelled"), "orange", "status,=,Cancelled"];
        }else if (doc.status === "Completed") {
            return [__("Completed"), "green", "status,=,Completed"];

        }
    },

}


